package com.simple.piger.constant;

import java.io.Serializable;

/**
 * 错误码规则：[A][B][ZZ]
 * <ul>
 * <li>[A] 异常分类（4：业务，5：系统）</li>
 * <li>
 * [B] 模块编号
 * <ul>
 * <li>0:共通</li>
 * <li>1:注册登录</li>
 * </ul>
 * </li>
 * <li>[ZZ] 序号</li>
 * </ul>
 */
public enum ErrorCode implements Serializable {


    // ===================================
    // 共通
    // ===================================
    INTERNAL_SERVER_ERROR(500, "服务器错误"),

    INTERNAL_SERVER_UPDATE(5001, "服务器维护中"),

    FORBIDDEN(403, "无访问权限"),

    INVALID_SMS(4000, "验证码错误"),

    INVALID_TOKEN(4001, "无效的令牌"),

    PARAMS_ERROR(4002, "请求参数错误"),

    RESOURCE_ERROR(4003, "资源定位错误"),

    FORMAT_ERROR(4004, "数据格式错误"),

    INVALID_PARAMS(4005, "数据校验错误"),

    UPLOAD_FAIL(4006, "图片上传失败"),

    UPLOAD_SIZE_ERROR(4007, "图片超出规定大小"),

    STATUS_TRANS_ERROR(4008, "状态转换异常"),

    REQUEST_BUSY(4009, "请求过于频繁"),

    RECORD_NOT_EXIST(404, "记录不存在"),

    //====================================
    //短信
    //====================================
    SMS_TIMEOUT(4009, "验证码超时"),

    SMS_FREQ_ERROR(4010, "短信发送过于频繁"),

    SMS_TEMPLATE_MATCH(4011, "模板与信息不匹配"),

    DUPLICATE_SUBMIT(4012, "重复提交"),

    REQUEST_FREQ_ERROR(4013, "请求频率过于频繁"),

    SMS_SERVICE_BUSY(4015, "短信暂时无法发送"),

    FORCE_UPDATE(4014, "强制升级"),

    SESSION_LAPSE(4016, "会话失效，请重新登录"),

    METHOD_NOT_ALLOW(4017, "方法不被支持"),

    MEDIATYPE_NOT_SUPPORT(4018, "不支持当前媒体类型"),

    VALID_IDCARD_ERROR(4019, "身份证验证失败"),

    NAME_OR_PWD_ERROR(4020, "用户名或密码错误"),

    PAY_CODE_LIMIT(4021, "您已输错5次，请次日重试"),

    PAY_CODE_PRE_LIMIT(4022, "您今日还能再输错两次"),

    SIGN_VALID_ERROR(4023, "签名验证失败"),

    USER_NOT_FIND(4024, "用户不存在"),

    IP_USER_BLK(4025, "黑名单用户"),

    SESSION_LOSE(4026, "会话失效"), //个人中心专用

    TONGDUN_FORBIDDEN(4027, "您的账号存在风险"),

    TONGDUN_FORBIDDEN_REDEVELOPE(4028, "您的账号存在风险，无法参加此活动"),

    ENGINE_EXIST(4029, "发动机号已存在"),

    FRAME_EXIST(4030, "车架号已存在"),

    PLATE_EXIST(4031, "车牌号已存在"),
    //经纪人更换登录手机号
    OLD_MOBILE_ERROR(4090, "原手机号错误"),

    MOBILE_SAME(4091, "新手机号不能与原手机号相同"),

    NEW_MOBILE_EXIST(4092, "该新手机号已注册,不能进行更换"),

    AGENT_CHANGE_BANK_CARD(4093, "银行卡更换失败，请检查银行卡号是否填写正确"),

    AGENT_BANK_CARD_SAME(4094, "新银行卡与原银行卡相同"),

    AGENT_INVITE_USER_EXIST(4095, "该用户已被邀请过"),

    MOBILE_NOT_BLANK(4096, "手机账户不能为空"),

    NOT_CREATE_DEALER_USER(4097, "您无权限创建账号"),

    CREATE_DEALER_USER_FAILED(4098, "销售员账号创建失败"),

    NOT_ENGINE_EXIST(4099, "该发动机号不存在，请核对"),

    // ===================================
    // 注册登录
    // ===================================
    REGISTERED(4101, "用户已经注册"),

    MOBILE_REGISTERD(4102, "手机号已经注册"),

    NOT_REGISTERD(4103, "手机号未注册"),

    OLD_PASS_ERROR(4104, "旧密码错误"),

    PASSWORD_ERROR(4105, "原密码错误"),

    ACCOUNT_NOT_USABBLE(4106, "账号被冻结，暂时无法登录"),

    MOBILE_ERROR(4107, "您输入的手机号有误"),

    NOT_HAVE_PWD(4108, "您还未设置密码请到个人中心设置"),

    USER_REAL_NAME_AUTH(4109, "您还没有实名认证"),

    PWD_SAME(4019, "新密码不能与原密码一致"),
    // ===================================
    // 资质审核
    // ===================================
    AUTH_FAIL(4050, "审核不通过"),
    AUTH_ABNORMAL(4052, "风控信息异常"),
    DRIVING_LIC_AUTH_FAIL(4051, "驾照审核未通过"),
    AUTH_INFO_FAIL(4059, "请检查资质审核信息"),
    NONE_AUTH_INFO(4057, "查询不到信息"),

    REAL_NAME_AUTH(4055, "您的注册信息未审核通过，请核对后提交！"),

    //违章查询
    VIOLATION_QUERY(4061, "违章查询失败"),
    //推广活动
    ACTIVITY_NOT_PARTICIPATION(4901, "未参与活动"),
    ACTIVITY_PARTICIPATION(4902, "已参与活动"),
    USER_ACCOUNT_BIND_ERROR(4903, "手机号与微信号不匹配"),
    EXTRACT_CODE_ERROR(4904, "获取提取凭证失败"),


    //个推失败
    GE_PUSH_FAIL(4071, "个推推送失败"),
    //展车数量超过限制
    SHOW_CAR_GREATER_THAN_LIMIT(4081, "展车数展车数量超过限制量"),

    //service-carmall
    SEARCH_EMPTY(5001, "未搜索到相关数据"),

    //service-common

    REPEAT_APPLY_DEALER(4501, "有重复的车商申请"),
    //====================================
    //app版本需要更新
    //====================================
    UPDATE_APP_VERSION(4201, "APP版本需要更新"),
    FORCE_UPDATE_APP_VERSION(4202, "APP版本需要强制更新"),

    // ===================================
    // 首页数据不能加入缓存的错误代码
    // ===================================
    HOME_DATA_ERROR(4302, "数据错误"),

    LOAN_BILL_EMPTY(4303, "您暂时还没有任何还款账单！"),
    LOAN_BILL_COMPLETION(4304, "您的账单已还清"),
    CONTRACT_NOT_FIND(4305, "未找到相关合同"),
    CONTRACT_CREATE_ERROR(4306, "合同生成失败!"),
    BIND_CARD_VERIFY_ERROR(4307, "身份验证失败!"),
    ORDER_RM_PRE_LOAN_ERROR(4308, "风控审核未通过!"),
    ORDER_MONEY_ERROR(4309, "支付金额不正确!"),
    LOAN_BILL_TERMINATION(4310, "您的合同已作废"),
    LOAN_ORDER_STATUS_ERROR(4311, "订单状态不正确"),
    LOAN_SIGN_ERROR(4312, "用户已签约"),
    LOAN_REPAYMENT_NOT_FIND(4313, "账单不存在"),
    LOAN_BILL_BAD_DEBT(4314, "坏账"),

    //支付-绑卡支付
    PAY_BACK_QUERY_ERROR(4401, "银行卡查询失败"),
    PAY_PAY_BILL_ERROR(4402, "获取支付凭证失败"),
    PAY_SIGN_BILL_ERROR(4403, "获取授权凭证失败"),
    PAY_CALL_BACK_ERROR(4404, "交易回调失败"),
    PAY_BIND_BACK_CLASH_ERROR(4405, "该银行卡已绑定"),
    PAY_BIND_BACK_INFO_ERROR(4406, "银行卡信息错误"),
    PAY_BIND_BACK_NONSUPPORT_ERROR(4406, "暂不支持该银行卡"),
    PAY_DEDUCT_ERROR(4407, "划扣失败"),
    PAY_NO_SIGN_ERROR(4408, "用户未签约"),
    PAY_PAYMENT_ERROR(4409, "支付失败"),
    PAY_BILL_ERROR(4410, "签约失败"),
    PAY_DEDUCT_NOT_HAVE_MONEY_ERROR(4411, "余额不足"),


    //支付订单
    PAY_USER_ORDER_NOT_FOUND_ERROR(4420, "支付订单不存在"),
    PAY_USER_ORDER_SAVE_ERROR(4421, "生成支付订单失败"),
    PAY_ERROR(4422, "支付失败"),
    PAY_CREATE_REPAYMENT_PLAN_ERROR(4423, "创建还款计划失败"),

    //存在未完成的订单
    ORDER_UNFINISHED(4500, "存在未完成的订单"),

    // ===================================
    // 业务错误
    // ===================================

    BUSINESS_INFO(9000, "业务消息提示"),

    BUSINESS_ERROR(9001, "业务错误"),

    QUERY_ERROR(9002, "查询失败"),

    SUBMIT_ERROR(9003, "提交失败");

    public int code;
    public String message;

    ErrorCode(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public static ErrorCode valueOf(int code) {
        ErrorCode[] errorCodes = ErrorCode.values();
        for (ErrorCode errorCode : errorCodes) {
            if (code == errorCode.code) {
                return errorCode;
            }
        }
        return INTERNAL_SERVER_ERROR;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}
